package com.catty.consum.subscribe;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SubscribeServiceBox {

	private static SubscribeServiceBox serviceBox;
	private List<String> subServicesList = new ArrayList<String>();
	private Map<String,List<String>> servicesAddressMap = new HashMap<String,List<String>>();
	
	private SubscribeServiceBox(){
		
	}
	
	public synchronized static SubscribeServiceBox getInstance(){
		if(null==serviceBox){
			serviceBox =  new SubscribeServiceBox();
		}
		return serviceBox;
	}
	
	public boolean addSubList(String interfaceName){
		
		return subServicesList.add(interfaceName);

	}
	
	public String subServiceListString (){
		if(null==serviceBox){
			return "";
		}
		StringBuffer sb = new StringBuffer();
		for(String service:subServicesList){
			sb.append(service);
			sb.append(";");
		}
		return sb.toString();
	}

	public Map<String,List<String>> getServicesAddressMap() {
		return servicesAddressMap;
	}

	public void setServicesAddressMap(Map<String,List<String>> servicesAddressMap) {
		this.servicesAddressMap = servicesAddressMap;
	}
	
	
}
